# from .models import *
# from rest_framework import serializers, status
# from .util import pwd_hash
# import re
#
#
# # 密码验证
# def my_validate(val):
#     try:
#         re.search('[A-Z]+', val).group()
#     except:
#         raise serializers.ValidationError('密码应包含大写字母')
#     if len(val) < 8:
#         raise serializers.ValidationError('密码应大于8位')
#         # return Response('密码太短')
#
#
# class UserSerializer(serializers.ModelSerializer):
#
#
#     def create(self, validated_data):
#         print(validated_data)
#         password = validated_data.pop('password')
#         validated_data['password'] = pwd_hash(password)
#         user_obj = User.objects.create(**validated_data)
#         return user_obj
#
#     class Meta:
#         model = User
#         fields = ['username', 'gender', 'age', 'phone_number', 'email']
#         extra_kwargs = {'password': {'write_only': True, "validators": [my_validate]}}

